package com.yxhl.zoume.core.func.pay.adapter;

import android.databinding.DataBindingUtil;
import android.view.View;
import android.view.ViewGroup;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yxhl.zoume.R;
import com.yxhl.zoume.core.func.pay.model.ExpressCarBillDetail;
import com.yxhl.zoume.databinding.BillItemInfoDataBinding;

import java.util.List;

import butterknife.ButterKnife;

/**
 * Created by vhawk on 12/20/16.
 */

public class ExpressCarBillDetailAdapter extends BaseQuickAdapter<ExpressCarBillDetail, ExpressCarBillDetailAdapter.ExpressCarBillDetailViewHolder> {

    public ExpressCarBillDetailAdapter(List<ExpressCarBillDetail> data) {
        super(R.layout.item_express_car_bill_detail, data);
    }

    @Override
    protected void convert(ExpressCarBillDetailViewHolder holder, ExpressCarBillDetail expressCarBillItemInfo) {
        BillItemInfoDataBinding binding = holder.getBinding();
        binding.setBillItemInfo(expressCarBillItemInfo);
    }

    @Override
    protected View getItemView(int layoutResId, ViewGroup parent) {
        BillItemInfoDataBinding binding = DataBindingUtil.inflate(mLayoutInflater, layoutResId, parent, false);
        View view = binding.getRoot();
        view.setTag(binding);
        return view;
    }

    @Override
    protected ExpressCarBillDetailViewHolder createBaseViewHolder(View view) {
        return new ExpressCarBillDetailViewHolder(view);
    }

    public class ExpressCarBillDetailViewHolder extends BaseViewHolder {

        private final BillItemInfoDataBinding binding;

        public ExpressCarBillDetailViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
            binding = (BillItemInfoDataBinding) view.getTag();
        }

        public BillItemInfoDataBinding getBinding() {
            return binding;
        }
    }
}
